package sfa.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import sfa.sc.DeleteSc;

public class DeleteController extends AbstractController {

	private DeleteSc deleteSc;
	
	public void setDeleteSc(DeleteSc deleteSc) {
		this.deleteSc = deleteSc;
	}

	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		request.setAttribute("request", request);
		request.setAttribute("session", request.getSession());
		
		return super.handleRequest(request, response);
	}
	
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String obs_no = request.getParameter("obs_no");
		System.out.println("obs_no=============>" + obs_no);
		
		deleteObs(obs_no);
		
		ModelAndView mav = new ModelAndView();
		mav.setViewName("redirect:/page/em/mn/list.do");
		return mav;
	}
	
	private void deleteObs(String obs_no) {
		deleteSc.deleteObs(obs_no);
	}
}
